package com.base.cn.platform.os.service.integralgood;

import com.base.cn.platform.os.common.mybatis.BaseBiz;
import com.base.cn.platform.os.common.mybatis.Pagination;
import com.base.cn.platform.os.common.utils.DataUtil;
import com.base.cn.platform.os.common.utils.ObjectUtils;
import com.base.cn.platform.os.common.utils.result.ResultUtil;
import com.base.cn.platform.os.dao.integralgood.IntegralCardVoucherDao;
import com.base.cn.platform.os.dao.integralgood.IntegralVirtualGoodDao;
import com.base.cn.platform.os.entity.integralgood.IntegralCardVoucher;
import com.base.cn.platform.os.entity.integralgood.IntegralVirtualGood;
import com.base.cn.platform.os.entity.integralgood.IntegralVirtualGoodExpand;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;


/**
 * 虚拟卡
 * @Author: Hello豆包
 * @Date: 2019/10/31 14:498
 */
@Service
public class IntegralVirtualGoodBiz extends BaseBiz<IntegralVirtualGood, IntegralVirtualGoodDao> {


    /**
     *分页虚拟数据
     * @param page
     * @param integralVirtualGood
     * @return
     */
    public PageInfo<IntegralVirtualGood> findListPage(Pagination page, IntegralVirtualGood integralVirtualGood){
        String s = whereSql(integralVirtualGood);
        return this.findPage(s, page, null);
    }







    /**
     * 设置sql
     * @param integralVirtualGood
     * @return
     */
     private  String whereSql(IntegralVirtualGood integralVirtualGood){
                 StringBuilder whereSql = new StringBuilder(" 1= 1 ");
                    if(ObjectUtils.isNotEmpty(integralVirtualGood)){
                        if(ObjectUtils.isNotEmpty(integralVirtualGood.getStatus())){
                            whereSql.append("and status = ").append(integralVirtualGood.getStatus());
                        }
                        if(ObjectUtils.isNotEmpty(integralVirtualGood.getName())){
                            whereSql.append("and name like '% ").append(integralVirtualGood.getName()).append("%'");
                        }
                    }
                    whereSql.append(" order by createTime desc");
               return  whereSql.toString();
    }



}
